package com.deke.order.controller;


import com.deke.entity.EduCourse;
import com.deke.order.service.OrderService;
import com.deke.order.vo.OrderVo;
import com.deke.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author ：Username 刘亦辰（59372312@qq.com）
 * @date ：Created in 2022/12/9 12:11
 * @description：
 * @modified By：
 * @version:
 **/
@RestController
@RequestMapping("/order/order/")
@Api(tags = "订单接口类")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/getAllOrder/{currentPage}/{pageSize}")
    @ApiOperation(value = "订单模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页码数",name = "currentPage"),
            @ApiImplicitParam(value = "每页显示行数",name = "pageSize"),
            @ApiImplicitParam(value = "前端实体类",name = "orderVo")
    })
    public Result<Map<String,Object>> getAllOrder(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody OrderVo orderVo){
        return orderService.queryAllByLimit(currentPage,pageSize,orderVo);
    }


    @RequestMapping("/queryOrderAndPayLog/{id}")
    @ApiOperation(value = "订单回显")
    @ApiImplicitParam(value = "订单序号",name = "id")
    public Result queryOrderAndPayLog(@PathVariable String id){
        return orderService.queryOrderAndPayLog(id);
    }

    @PostMapping("/queryAllTeacherBYTeacherName/{teacherName}")
    @ApiOperation(value = "查询老师的信息")
    @ApiImplicitParam(value = "老师名称",name = "teacherName")
    public Result queryAllTeacherBYTeacherName(@PathVariable String teacherName){
        return orderService.queryAllTeacherBYTeacherName(teacherName);
    }

    @PostMapping("/queryAllCourse/{courseId}")
    @ApiOperation(value = "查询课程信息")
    @ApiImplicitParam(value = "课程号",name = "courseId")
    public Result<List<EduCourse>> queryAllCourse(@PathVariable String courseId){
        return orderService.queryAllCourse(courseId);
    }

    @PostMapping("/queryAllMemberById/{memberId}")
    @ApiOperation(value = "查看用户信息")
    @ApiImplicitParam(value = "用户id",name = "memberId")
    public Result queryAllMemberById(@PathVariable String memberId){
        return orderService.queryAllMemberById(memberId);
    }
    /**
     * 根据课程id和会员id查询支付状态
     * @param courseId
     * @param memberId
     * @return
     */
    @PostMapping("getOrderStatus/{id}/{HuiYuanId}")
    public Result getOrderStatus(@PathVariable(name = "id") String courseId, @PathVariable(name = "HuiYuanId") String memberId){
        return (orderService.getOrderStatus(courseId, memberId));
    }
    
    /**
     * @create by: 陈昂（731712841@qq.com）
     * @description:
     * @create time: 2023/2/12 19:37
     * @param null
     * @return 
     */
    @PostMapping("deleteOrder/{id}")
    public Result deleteOrder(@PathVariable String id){
        return orderService.deleteOrder(id);
    }
}